package com.github.wxiaoqi.security.auth.util.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.wxiaoqi.security.auth.config.JwtProperties;
import com.github.wxiaoqi.security.common.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.jwt.JWTHelper;

/**
 * Created by ace on 2017/9/10.
 */
@Component
public class JwtTokenUtil {
    
    @Autowired
    private JwtProperties jwtProperties;


    public String generateToken(IJWTInfo jwtInfo) throws Exception {
        return JWTHelper.generateToken(jwtInfo, jwtProperties.getUserPriKey(),jwtProperties.getExpire());
    }

    public IJWTInfo getInfoFromToken(String token) throws Exception {
        return JWTHelper.getInfoFromToken(token, jwtProperties.getUserPubKey());
    }


}
